﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <title>注册</title>
    <link rel="stylesheet" href="css/style.css?v=1.11">
    <link rel="stylesheet" href="css/index.css?v=1.11">
    <script src="js/jquery-1.8.3.min.js?v=1.11"></script>
    <script src="js/flexible.js?v=1.11"></script>
    <script src="layer-mobile/layer.js?v=1.11"></script>

</head>
<body>
    <div class="login">
        <div class="login-body">

            <div class="login-logo"><img src="/image/cricl-logo.png" /></div>
            <div class="login-btn">
                <img src="/image/iphone.png" class="myuser" />
                <input id="txtMobile" type="number" placeholder="请输入手机号" autofocus="autofocus" />
                <select id="select" disabled="disabled">
                    <option value="0086">中国</option>
                    <option value="00852">香港</option>
                    <option value="00853">澳门</option>
                    <option value="00886">台湾</option>
                    <option value="0081">日本</option>
                    <option value="0065">新加坡</option>
                    <option value="0060">马来西亚</option>
                    <option value="0063">菲律宾</option>
                    <option value="0084">越南</option>
                    <option value="0066">泰国</option>
                    <option value="0082">韩国</option>
                    <option value="0091">印度</option>
                    <option value="007">俄罗斯</option>
                    <option value="001">美国</option>
                    <option value="001">加拿大</option>
                    <option value="0044">英国</option>
                    <option value="0033">法国</option>
                    <option value="0049">德国</option>
                    <option value="0039">意大利</option>
                    <option value="0061">澳大利亚</option>
                    <option value="0064">新西兰</option>
                    <option value="0046">瑞典</option>
                    <option value="0041">瑞士</option>
                    <option value="0031">荷兰</option>
                    <option value="0034">西班牙</option>
                    <option value="00351">葡萄牙</option>
                </select>
            </div>
            <div class="login-btn">
                <img src="/image/code.png" class="mycode" />
                <input id="txtValationCode" type="number" placeholder="验证码" /><input id="btnGetCode" type="button" value="获取验证码" class="fr login-code" />
            </div>
            <div class="login-btn">
                <input id="txtRefCode" type="text" placeholder="请输入邀请码" />
            </div>
            <div class="login-regsion">
                <input id="btnLogin" type="button" value="注册" />
                <a href="/login.html">已有账号，去登录</a>
            </div>
        </div>

    </div>

</body>

</html>
<script>
    $(document).ready(function () {

        var _height = $(document).height();
        $('.login').css('height', _height);
        $('#txtMobile').trigger("click").focus();


        var iphoneNum = '';
        $("#txtMobile").on('input propertychange', function () {
            iphoneNum = $('#select').val() + $(this).val();
        })

        $('#select').on('click', function () {
            iphoneNum = $(this).val() + $("#txtMobile").val();
        })

        $("#btnLogin").click(function () {
            
            if ($('#txtRefCode').val() == '') {
                layer.open({
                    content: '请输入邀请码',
                    skin: 'msg',
                    time: 2
                });

            } else {
                $.ajax({
                    type: "POST",
                    url: "/API/AjaxHandler.ashx?Action=KongtouWeb.UserAjax.UserRegister",
                    data: {
                        mobile: $("#txtMobile").val(),
                        referralCode: $("#txtRefCode").val(),
                        code: $("#txtValationCode").val()
                    },
                    async: false,
                    error: function (request) {
                        layer.open({
                            content: '系统异常',
                            skin: 'msg',
                            time: 2
                        });
                    },
                    success: function (data) {
                        if (data.status == "1") {
                            localStorage.setItem("ktUserID", data.message);
                            location.href = "/index.html";
                        }
                        else {

                            layer.open({
                                content: data.message,
                                skin: 'msg',
                                time: 2
                            });
                        }

                    }
                });
            }
            
        })

        $("#btnGetCode").click(function () {

            $.ajax({
                type: "POST",
                url: "/API/AjaxHandler.ashx?Action=KongtouWeb.UserAjax.GetVerificationCode",
                data: {
                    mobile: $("#txtMobile").val() ,
                    type: 1
                },
                async: false,
                error: function (request) {
                    layer.open({
                        content: '系统异常',
                        skin: 'msg',
                        time: 2
                    });
                },
                success: function (data) {
                    if (data.status == "1") {
                        messsge($('#btnGetCode'));
                        layer.open({
                            content: '验证码发送成功',
                            skin: 'msg',
                            time: 2
                        });
                    }
                    else {
                        layer.open({
                            content: data.message,
                            skin: 'msg',
                            time: 2
                        });

                    }

                }
            });

        });

    });
</script>